package com.example.icongyou.api;

import com.example.icongyou.bean.TeamAssignment;
import retrofit2.Call;
import retrofit2.http.*;

import java.math.BigDecimal;
import java.util.List;

public interface TeamAssignmentApi {

    // 创建团队作业 - 对应后端的 @PostMapping
    @POST("team-assignments")
    Call<TeamAssignment> createTeamAssignment(@Body TeamAssignment teamAssignment);

    // 根据ID获取团队作业 - 对应后端的 @GetMapping("/{id}")
    @GET("team-assignments/{id}")
    Call<TeamAssignment> getTeamAssignment(@Path("id") Long id);

    // 根据团队ID获取团队作业列表 - 对应后端的 @GetMapping("/team/{teamId}")
    @GET("team-assignments/team/{teamId}")
    Call<List<TeamAssignment>> getTeamAssignmentsByTeam(@Path("teamId") Long teamId);

    // 根据作业ID获取团队作业列表 - 对应后端的 @GetMapping("/assignment/{assignmentId}")
    @GET("team-assignments/assignment/{assignmentId}")
    Call<List<TeamAssignment>> getTeamAssignmentsByAssignment(@Path("assignmentId") String assignmentId);

    // 根据提交者获取团队作业列表 - 对应后端的 @GetMapping("/submitter/{submittedBy}")
    @GET("team-assignments/submitter/{submittedBy}")
    Call<List<TeamAssignment>> getTeamAssignmentsBySubmitter(@Path("submittedBy") Long submittedBy);

    // 获取所有团队作业 - 对应后端的 @GetMapping
    @GET("team-assignments")
    Call<List<TeamAssignment>> getAllTeamAssignments();

    // 更新团队作业 - 对应后端的 @PutMapping("/{id}")
    @PUT("team-assignments/{id}")
    Call<TeamAssignment> updateTeamAssignment(@Path("id") Long id, @Body TeamAssignment teamAssignment);

    // 更新分数和优秀状态 - 对应后端的 @PatchMapping("/{id}/score")
    @PATCH("team-assignments/{id}/score")
    Call<Void> updateScore(@Path("id") Long id,
                           @Query("score") BigDecimal score,
                           @Query("isExcellent") Integer isExcellent);

    // 提交作业 - 对应后端的 @PostMapping("/{id}/submit")
    @POST("team-assignments/{id}/submit")
    Call<Void> submitAssignment(@Path("id") Long id, @Query("filePath") String filePath);

    // 删除团队作业 - 对应后端的 @DeleteMapping("/{id}")
    @DELETE("team-assignments/{id}")
    Call<Void> deleteTeamAssignment(@Path("id") Long id);

    // 获取优秀作业列表 - 对应后端的 @GetMapping("/excellent")
    @GET("team-assignments/excellent")
    Call<List<TeamAssignment>> getExcellentAssignments();

    // 根据团队ID和作业ID获取作业 - 对应后端的 @GetMapping("/team/{teamId}/assignment/{assignmentId}")
    @GET("team-assignments/team/{teamId}/assignment/{assignmentId}")
    Call<TeamAssignment> getByTeamAndAssignment(@Path("teamId") Long teamId,
                                                @Path("assignmentId") String assignmentId);

    // 统计团队作业数量 - 对应后端的 @GetMapping("/team/{teamId}/count")
    @GET("team-assignments/team/{teamId}/count")
    Call<Integer> countByTeam(@Path("teamId") Long teamId);

    // 统计作业提交数量 - 对应后端的 @GetMapping("/assignment/{assignmentId}/count")
    @GET("team-assignments/assignment/{assignmentId}/count")
    Call<Integer> countByAssignment(@Path("assignmentId") String assignmentId);
}